package com.yiwenup.leetcode.top_interview_150;

/**
 * 文件描述
 *
 * @Project struct-algorithm
 * @Package com.yiwenup.leetcode.top_interview_150
 * @Author yiwenup
 * @Date 2024-12-09 19:13:51
 * @Description https://leetcode.cn/problems/two-sum-ii-input-array-is-sorted/description/?envType=study-plan-v2&envId=top-interview-150
 */
public class No0167 {
    public int[] twoSum(int[] numbers, int target) {
        int left = 0;
        int right = left + 1;
        while(left < numbers.length - 1) {
            int l = numbers[left];
            while(numbers[right] + l < target) {
                if(right == numbers.length - 1) {
                    break;
                }
                right++;
            }
            if(numbers[right] + l == target) {
                return new int[]{left+1, right+1};
            } else {
                left++;
                right = left + 1;
            }
        }
        return new int[]{left + 1, right + 1};
    }
}
